package com.hzhc.controller.message;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzhc.annotation.SysTemLog;
import com.hzhc.common.BaseController;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.SmsLogService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.utils.TokenUtil;
import com.hzhc.vo.SmsLogVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author dongcy
 * @date 2024/6/17 11:04
 * @description SmsLogController
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/smsLog")
public class SmsLogController extends BaseController {

    private final SmsLogService logService;

    /**
     * 发送日志 列表
     * @param request
     * @param vo
     * @return
     */
    @RequestMapping("/getSmsLogList")
    public ResultUtil<List<SmsLogVo>> getSmsLogList(HttpServletRequest request, @RequestBody SmsLogVo vo){
        Page<SmsLogVo> page = new Page<>(vo.getPageIndex(), vo.getPageSize());
        List<SmsLogVo> list = logService.getSmsLogList(page,vo);
        return ResultUtil.build(list,page.getTotal(),page.getPages(), ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 发送日志 新增
     * @param request
     * @param vo
     * @return
     */
    @RequestMapping("/addSmsLog")
    @SysTemLog(operModul = "短信设置-发送日志添加", operType = "添加", operDesc = "车辆添加功能", modular = "PC")
    public ResultUtil<T> addSmsLog(HttpServletRequest request,@RequestBody SmsLogVo vo){
        Long userID = TokenUtil.getUserID(request);
        vo.setUserId(userID);
        return logService.addSmsLog(vo);
    }


}
